<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Document</title>
	</head>
	<body>
		<script type="text/javascript">
			//箭头函数
			//常规语法定义函数
			// function funcName(params){
			// 	return params+2;
			// }
			// console.log(funcName(2));
			//箭头函数定义
			// var funcName=(params)=>params+2;
			// console.log(funcName(2));
			
			//箭头函数1
			// function Counter(){
			// 	this.num=0;
			// 	this.timer=setInterval(function add(){
			// 		this.num++;
			// 		console.log(this.num);
			// 	},1000);
			// }
			// var a=new Counter();
			
			//箭头函数2
			function Counter(){
				this.num=0;
				this.timer=setInterval(()=>{
					this.num++;
					console.log(this.num);
				},1000);
			}
			var a =new Counter();
		</script>
	</body>
</html>